chore: add public API alerting#4089
Conversation
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
2 similar comments
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
There was a problem hiding this comment.
Pull request overview
Adds targeted Slack alerting for Public API 409 Conflict errors (to support manual remediation of conflicting identities), and extends the shared Slack library with a dedicated channel + webhook mapping.
Changes:
- Added
SlackChannel.CDP_LFX_SELF_SERVE_ALERTSto route LFX self-serve conflict alerts separately. - Mapped the new channel to
CDP_LFX_SELF_SERVE_ALERTS_SLACK_WEBHOOK_URL. - Updated the Public API
errorHandlerto detectConflictErrorand send a Slack notification on 409s.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| services/libs/slack/src/types.ts | Adds a new SlackChannel enum value for LFX self-serve conflict alerting. |
| services/libs/slack/src/channels.ts | Adds env var mapping for the new channel (but currently introduces a TypeScript typing error). |
| backend/src/api/public/middlewares/errorHandler.ts | Sends a Slack notification when a ConflictError occurs in the public API. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const log = getServiceLogger() | ||
|
|
||
| const CHANNEL_WEBHOOK_URLS: Record<SlackChannel, string | undefined> = { | ||
| const CHANNEL_WEBHOOK_URLS: Record = { |
There was a problem hiding this comment.
This looks like a legit regression - the types are gone now for the constant.
| const log = getServiceLogger() | ||
|
|
||
| const CHANNEL_WEBHOOK_URLS: Record<SlackChannel, string | undefined> = { | ||
| const CHANNEL_WEBHOOK_URLS: Record = { |
There was a problem hiding this comment.
This looks like a legit regression - the types are gone now for the constant.
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 2edd497. Configure here.
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
| const error = new ConflictError('Conflicting identities') | ||
| Object.defineProperty(error, 'memberIds', { | ||
| value: memberIds, | ||
| enumerable: false, | ||
| configurable: true, | ||
| }) | ||
| throw error |

Issue reported by the LF SS team: https://linuxfoundation.atlassian.net/browse/LFXV2-1578?focusedCommentId=111986&sourceType=mention. The 409 error is thrown when the LF SS api tries to query our API for 2 identities that belong to different users. For now we want to fix these profiles manually. This will be given to the data quality team.
This pull request enhances error handling and alerting for the public API by introducing a new Slack alert channel specifically for conflict errors (HTTP 409). It also updates the Slack integration to support this new channel. The most important changes are grouped below:
Error Handling Improvements:
ConflictErrorin the public API'serrorHandlermiddleware, which now sends a Slack notification to the newCDP_LFX_SELF_SERVE_ALERTSchannel when a conflict occurs, providing request and error details.ConflictErrorfrom@crowd/common.Slack Integration Updates:
CDP_LFX_SELF_SERVE_ALERTSinSlackChannelto support targeted alerting.CDP_LFX_SELF_SERVE_ALERTSchannel, using its corresponding environment variable for the webhook URL.Note
Low Risk
Low risk: adds Slack alerting and logging for
ConflictError(HTTP 409) in the public API plus a new Slack channel/env var mapping, without changing success-path behavior or data handling.Overview
Adds targeted Slack alerting for public API 409 conflicts:
errorHandlernow special-casesConflictError, logs a warning, and posts a structured message (including optionalmemberIds) to the newCDP_LFX_SELF_SERVE_ALERTSchannel before returning the normal 409 JSON.Updates
resolveMemberByIdentitiesto attach the conflictingmemberIdsto the thrownConflictErrorfor alert context, and extends the Slack library with theCDP_LFX_SELF_SERVE_ALERTSenum value and webhook env var mapping.Reviewed by Cursor Bugbot for commit 142d894. Bugbot is set up for automated code reviews on this repo. Configure here.